local yingshi = fk.CreateSkill{
    name = "XD__yingshi"
}
Fk:loadTranslationTable{
    ["XD__yingshi"] = "应势",
    [":XD__yingshi"] = "回合技，当一名角色使用【杀】或普通锦囊牌选择目标时，你可令此牌对其中一个目标无效，然后后者观看牌堆顶的两张牌，并可以对前者使用其中一张【杀】或普通锦囊牌（有距离限制），若其未因此法使用牌，你减1点体力上限。",
    ["#XD__yingshi"] = "应势：是否令%arg对其中一个目标无效",
    ["#XD__yingshi-use"] = "应势：对 %src 使用牌堆顶的一张【杀】或普通锦囊牌，否则 %dest 将减1点体力上限",
}

yingshi:addEffect(fk.AfterCardUseDeclared, {
    anim_type = "control",
    can_trigger = function (self, event, target, player, data)
        return (data.card.trueName == "slash" or data.card:isCommonTrick()) and player:hasSkill(yingshi.name) and player:usedSkillTimes(yingshi.name, Player.HistoryTurn) == 0 and #data.tos > 0
    end,
    on_cost = function (self, event, target, player, data)
        local tos = player.room:askToChoosePlayers(player, {
            targets = data.tos,
            skill_name = yingshi.name,
            max_num = 1,
            min_num = 1,
            prompt = "#XD__yingshi:::"..data.card:toLogString(),
            extra_data = table.map(data.tos, Util.IdMapper),
            target_tip_name = "addandcanceltarget_tip",
        })
        if #tos > 0 then
            event:setCostData(self, {tos = tos})
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        data.nullifiedTargets = data.nullifiedTargets or {}
        table.insert(data.nullifiedTargets, to)
        local cards = {}
        for i = 1, math.min(2,#room.draw_pile), 1 do
            table.insert(cards, room.draw_pile[i])
        end
        local ids = table.filter(cards, function (cardID)
            return Fk:getCardById(cardID).trueName == "slash" or Fk:getCardById(cardID):isCommonTrick()
        end)
        local use = room:askToUseRealCard(to, {
            pattern = ids,
            expand_pile = cards,
            skill_name = yingshi.name,
            extra_data = {
                exclusive_targets = {data.from.id},
                bypass_times = true,
                extraUse = true,
                not_passive = true,
            },
            prompt = "#XD__yingshi-use:"..data.from.id..":"..player.id
        })
        if not use then
            room:changeMaxHp(player, -1)
        end
    end,
})

return yingshi